package cn.com.web.Servlet;

import cn.com.domain.PageBean;
import cn.com.domain.Room;
import cn.com.service.CustomerService;
import cn.com.service.RoomService;
import cn.com.service.impl.CustomerServiceImpl;
import cn.com.service.impl.RoomServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/FindRoomByPageServlet")
public class FindRoomByPageServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String currentPage=request.getParameter("currentPage");//当前页码
        String rows = request.getParameter("rows");
        RoomService service=new RoomServiceImpl();
        if (currentPage==null && rows ==null){
            currentPage="1";
            rows="5";
        }
        PageBean<Room> pb=service.findRoomByPage(currentPage,rows);
        System.out.println(pb);
        request.setAttribute("pb",pb);
        request.getRequestDispatcher("/Room.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
